package andriod.samples;

import java.util.ArrayList;



import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;

import android.view.View.OnClickListener;

public class ActivityControls_1 extends Activity {
	
	OnClickListener listener = null;
	
	Button button;
	
	CheckBox plain = null;
	CheckBox serif = null;
	CheckBox italic = null;
	CheckBox bold = null;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);;
		setContentView(R.layout.activity_controls_1);
		
		listener = new OnClickListener() {
			public void onClick(View v) {
				String r = "";
				if(plain.isChecked()){
					r = r + "," + plain.getText();
				}
				if(serif.isChecked()){
					r = r + "," + serif.getText();
				}
				if(italic.isChecked()){
					r = r + "," + italic.getText();
				}
				if(bold.isChecked()){
					r = r + "," + bold.getText();
				}
				setTitle("checked:" + r);
			}
		};
		
		plain = (CheckBox) findViewById(R.id.plain_cb);
		serif = (CheckBox) findViewById(R.id.serif_cb);
		italic = (CheckBox) findViewById(R.id.italic_cb);
		bold = (CheckBox) findViewById(R.id.bold_cb);
		
		button = (Button) findViewById(R.id.GetCheckBoxValueBtn);
		button.setOnClickListener(listener);
		
		find_and_modify_view();
	}


	private static final String[] mCountries = { "China" ,"Russia", "Germany",
			"Ukraine", "Belarus", "USA" };

	private void find_and_modify_view() {
		Spinner spinner_c = (Spinner) findViewById(R.id.spinner_1);
		ArrayList<String> allcountries = new ArrayList<String>();
		for (int i = 0; i < mCountries.length; i++) {
			allcountries.add(mCountries[i]);
		}
		ArrayAdapter<String> aspnCountries = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, allcountries);
		
		aspnCountries.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner_c.setAdapter(aspnCountries);
		
		
		
		Spinner spinner_2 = (Spinner) findViewById(R.id.spinner_2);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.countries, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner_2.setAdapter(adapter);

	}

}
